export default {
  data() {
    return {
      pageIndex: NaN,
      totalNum: 0,
      bussinesslist: [],
      typeList: {
        0: {
          title: '成员',
          title1: '审核',
          url: '/pages_common/pages_me/menber/menber',
        },
        4: {
          title: '余额',
          title1: '变动',
          url: '',
        },
        5: {
          title: '寻车',
          title1: '',
          url: '/pages_findCar/detailsForTheCar/detailsForTheCar?goodsid=',
        },
        10: {
          title: '寻配件',
          title1: '',
          url:
            '/pages_order/accessoryOrder/quoteOrderDetail/quoteOrderDetail?id=',
        },
        20: {
          title: '订单',
          title1: '通知',
          url: '/pages_afterSales/order/orderDetail/orderDetail?id=',
        },
        25: {
          title: '订单',
          title1: '通知',
          url: '/pages_order/carOrderDetail/carOrderDetail?id=',
        },
        15: {
          title: '订单',
          title1: '通知',
          url:
            '/pages_order/carGoodsOrder/salesOrderDetail/salesOrderDetail?id=',
        },
        30: {
          title: '检测',
          title1: '回执',
          url: '/pages_afterSales/visualCheck/visualCheckReport?id=',
        },
        35: {
          title: '检测',
          title1: '回执',
          url: '/pages_afterSales/dismantleCheck/dismantleCheckReport?id=',
        },
        40: {
          title: '检测',
          title1: '回执',
          url: '/pages_afterSales/qualityTest/qualityTest?id=',
        },
        45: {
          title: '检测',
          title1: '回执',
          url: '/pages_afterSales/constructionOrder/constructionOrder?id=',
        },
      },
      showEmpty: false,
      pageLoading: false, //初始化加载效果
    }
  },

  computed: {
    isMore() {
      if (
        !Number.isNaN(this.pageIndex) &&
        this.totalNum <= this.pageIndex * 10
      ) {
        return false
      }
      return true
    },
  },
  // watch: {
  // 	isMore(val){
  // 		if(!val){
  // 			uni.showToast({
  // 				title: '没有更多了',
  // 				icon: 'none'
  // 			})
  // 		}
  // 	}
  // },
  onLoad() {
    this.getList()
  },
  onReachBottom() {
    if (this.isMore) {
      this.getList()
    } else {
      uni.showToast({
        title: '没有更多了',
        icon: 'none',
      })
    }
  },
  methods: {
    bussclick(type, id) {
      if (this.typeList[type] && this.typeList[type].url) {
        uni.navigateTo({
          url:
            type === 0 ? this.typeList[type].url : this.typeList[type].url + id,
        })
      }
    },

    //获取列表
    getList() {
      if (this.pageLoading) {
        uni.showLoading({
          title: '加载中',
        })
      }

      if (Number.isNaN(this.pageIndex)) {
        this.pageIndex = 1
      } else {
        this.pageIndex++
      }
      this.$api.news
        .getNoticeList({
          PageIndex: this.pageIndex,
          PageSize: 10,
        })
        .then((res) => {
          if (res.data.total === 0) {
            this.showEmpty = true
          } else if (this.pageIndex === 1) {
            this.bussinesslist = res.data.list
            this.totalNum = res.data.total
          } else {
            this.bussinesslist = this.bussinesslist.concat(res.data.list)
          }
          if (this.pageLoading) {
            uni.hideLoading()
          } else {
            this.pageLoading = true
          }
        })
        .catch(() => {
          if (this.pageLoading) {
            uni.hideLoading()
          } else {
            this.pageLoading = true
          }
        })
    },
  },
}
